<?php
/**
 * @link https://www.kancloud.cn/cleverstone/ymb2
 * @copyright Copyright (c) 2020 Yii Manager Software LLC
 */

namespace common\models;

/**
 * 应用日志
 */
class AppLogsService
{
    /**
     * 获取指定时间段内指定级别的日志
     * @param string $startDate 开始日期
     * @param string $endDate 结束日期
     * @param string $level 级别
     * @return array
     */
    public static function getAppLogsByInterval($startDate, $endDate, $level = 'error'):array
    {
        return AppLogs::query('id,category,created_at')->where('level=:level', [':level' => $level])->andWhere(['between', 'created_at', $startDate, $endDate])->orderBy('created_at DESC')->all();
    }
}